/*This file is part of WZLibCP.

 *  WZLibCP is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

 *  WZLibCP is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

 *  You should have received a copy of the GNU General Public License
    along with WZLibCP.  If not, see <http://www.gnu.org/licenses/>.
		
	Author: calc0000
*/
#ifndef __WZLIB_WZDIRECTORY_H
#define __WZLIB_WZDIRECTORY_H
#include "WZLibConfig.h"

#include <string>
#include <vector>

#include "WZObject.h"
#include "WZObjectCollection.h"

namespace WZLib{
	class WZImage;
	/**\brief Represents a WZDirectory in a WZFile.

	A WZDirectory is a structure that contains, as children, either
	WZImage s or WZDirectory s (accessible via subDirs and childImages).
	*/
	class WZDirectory:public WZObject{
	protected:
		//!WZObjectCollection that contains the children directories of this directory.
		WZObjectCollection			_subDirs;
		//!WZObjectCollection that contains the children images of this directory.
		WZObjectCollection			_childImages;
		//!The total size in the file of this directory.
		int							_blockSize;
		//!The checksum of this directory (all the bytes added together).
		int							_checksum;
		//!The offset of the directory declaration in the file.
		unsigned int				_offset;
	public:
		//Constructor
		/**\brief Constructor for WZDirectory.

		There should be no need for an end-user to call this constructor,
		as I have not and do not currently plan to implement wz file writing
		in WZLibCP.

		This is automatically called by WZFile 's constructor and 
		WZDirectory::parse to create new WZDirectory s.

		\param name The name of the WZDirectory.
		*/
		ctor						WZDirectory	(std::string name="");
		//Destructor
		/**\brief Destructor for WZDirectory.

		Deletes every object in _subDirs and _childImages.
		*/
		dtor						~WZDirectory();
		//Getters/Setters
		//!Get the WZObjectCollection containing children directories of this directory.
		WZObjectCollection&			subDirs();
		//!Get the WZObjectCollection containing children images of this directory.
		WZObjectCollection&			childImages();
		//!The size of this WZDirectory in the file.
		int&						blockSize();
		//!The checksum of this directory.
		int&						checksum();
		//!The offset of this directory in the file.
		unsigned int&				offset();
		//Methods
		/**\brief Parse the WZDirectory.

		There should be no need for an end-user to call this method, as WZFile::parse
		and WZDirectory::parse itself call this method as necessary.  This method simply
		parses the WZDirectory, populating _subDirs and _childImages with their respective
		elements.

		\param reader A WZBinaryReader that is seeked to the beginning of the directory.
		*/
		ErrorCode					parse		(WZBinaryReader* reader);
	};
};

#endif